package com.qfjy.student.zhangqingqqing.sort;

/**
 * @Author zhangqingqing
 * @Date 2021/6/23 20:43
 */

public class Maopao {
    public static void main(String[] args) {
        //升序排列
        int[] arr = {9,21,34,1,17};
        for(int i = 0; i< arr.length - 1; i++) {
            for(int j = 0;j< arr.length - i -1;j++) {
                if(arr[j] > arr[j+1]) {
                    int temp = arr[j];
                    arr[j] = arr[j+1];
                    arr[j+1] = temp;
                }
            }
        }
        for (int i : arr) {
            System.out.print(i + " ");
        }
        //降序排列
        int[] arr2 = {9,21,34,1,17};
        for(int i = 0; i< arr2.length - 1; i++) {
            for(int j = 0;j< arr2.length - i -1;j++) {
                if(arr2[j] < arr2[j+1]) {
                    int temp = arr2[j];
                    arr2[j] = arr2[j+1];
                    arr2[j+1] = temp;
                }
            }
        }
        for (int i : arr2) {
            System.out.print(i + " ");
        }
    }
}
